<script setup lang="ts">
import { ref, onMounted } from "vue";
import {
  onLaunch,
  onReady,
  onHide,
  onUnload,
  onLoad,
  onShow,
} from "@dcloudio/uni-app";
import { redirectToOriginalPage } from "@/utils/auth.js";
import { get_qr } from "@/api/warm.js";
const sceneType = ref(""); // type:1=暖心房,2=工人加入项目;
const sceneData = ref("");
const isUpload = ref("0"); //是否上传

// 获取二维码的参数
onLaunch((query) => {});

onShow(async (options) => {
  const token = uni.getStorageSync("token");
  const useInfo = uni.getStorageSync("useInfo");

  // 扫码了
  if (options.query && options.query.scene) {
    const scene = decodeURIComponent(options.query.scene);
    let param = scene;
    sceneData.value = param.split("=")[1]; //扫码参数
    uni.setStorageSync("sceneData", sceneData.value);
    uni.setStorageSync("sceneType", 1);
  } else {
    sceneType.value = "";
    uni.setStorageSync("sceneData", sceneData.value);
    uni.setStorageSync("sceneType", "");
  }

  if (sceneData.value !== "") {
    console.log("扫码了", sceneData.value);
    uni.setStorageSync("sceneType", "");
    uni.setStorageSync("invite_corp", "");
    uni.setStorageSync("invite_user", "");
    uni.setStorageSync("project_id", "");
    const res = await get_qr({
      qr: sceneData.value,
    });
    if (res.code == 1) {
      if (res.data.type) {
        uni.setStorageSync("sceneType", res.data.type);
      }
      if (res.data.invite_user) {
        uni.setStorageSync("invite_user", res.data.invite_user);
      }
      if (res.data.invite_corp) {
        uni.setStorageSync("invite_corp", res.data.invite_corp);
      }
      if (res.data.project_id) {
        uni.setStorageSync("project_id", res.data.project_id);
      }
      console.log("扫码登录成功");
      uni.reLaunch({
        url: "/pages/common/index",
      });
    } else {
      uni.showToast({
        icon: "none",
        title: res.msg,
      });
      uni.reLaunch({
        url: "/pages/common/informationCollection/stopService",
      });
    }
  } else {
    console.log("没有扫码");
    uni.setStorageSync("sceneData", ""); //删除扫码值
    uni.setStorageSync("sceneType", ""); //
  }
});

onHide(() => {
  // console.log('进入后台了')
  // uni.setStorageSync('token', '')
  // uni.setStorageSync('useInfo', '')
  // uni.setStorageSync("isUpload", "0"); //清除上传状态
  // uni.setStorageSync("sceneType", "");
  // uni.setStorageSync("invite_corp", "");
  // uni.setStorageSync("invite_user", "");
  // uni.setStorageSync("project_id", "");
});
onUnload(() => {
  // uni.setStorageSync('token', '')
  // uni.setStorageSync('useInfo', '')
  // uni.setStorageSync("isUpload", "0"); //清除上传状态
  // uni.setStorageSync("sceneType", "");
  // uni.setStorageSync("invite_corp", "");
  // uni.setStorageSync("invite_user", "");
  // uni.setStorageSync("project_id", "");
});
</script>

<style lang="scss">
.no-blue-outline {
  outline: none;
  /* 移除轮廓 */
}

.no-blue-outline:active {
  background-color: transparent;
  /* 移除活动状态下的背景色 */
}

/* 调整下拉内容层的样式 */
.delUp :deep(.u-dropdown__content) {
  z-index: 1001;
  /* 提高下拉内容的层级 */
  // pointer-events: auto;
  height: 300rpx !important;
  // border: 1px solid;
}

@import "@/static/css/common.scss";
@import "uview-plus/index.scss";

/* #ifdef APP-PLUS ||MP-WEIXIN */
checkbox .wx-checkbox-input {
  border-radius: 10% !important;
  border: 2rpx solid #dfdfdf; // 将边框颜色深化
  padding: 2px;
  width: 30rpx;
  height: 30rpx;
  color: transparent !important;
  // box-shadow: 0 0 5px rgba(0, 0, 0, 0.3); // 添加阴影
  transition: all 0.3s; // 添加过渡效果
}

checkbox .wx-checkbox-input.wx-checkbox-input-checked {
  color: #cca05f !important;
  border: 3rpx solid #cca05f; // 切换到蓝色边框，增大边框宽度
  padding: 2px;
  width: 30rpx;
  height: 30rpx;
  // background: #CCA05F !important; // 选中时的背景色改为蓝色
  // box-shadow: 0 0 10px rgba(62, 113, 244, 0.5); // 选中时的阴影效果更明显
  transform: scale(0.9); // 当选中时缩小复选框
}

.wx-checkbox-input.wx-checkbox-input-checked {
  // border: none !important;
}

radio .wx-radio-input {
  border-radius: 50% !important;
  border: 2rpx solid #dfdfdf; // 将边框颜色深化
  padding: 2px;
  width: 30rpx;
  height: 30rpx;
  color: transparent !important;
  // box-shadow: 0 0 5px rgba(0, 0, 0, 0.3); // 添加阴影
  transition: all 0.3s; // 添加过渡效果
}

radio .wx-radio-input.wx-radio-input-checked {
  color: #cca05f !important;
  border: 3rpx solid #cca05f; // 切换到蓝色边框，增大边框宽度
  padding: 2px;
  width: 30rpx;
  height: 30rpx;
  background: #cca05f !important; // 选中时的背景色改为蓝色
  // box-shadow: 0 0 10px rgba(62, 113, 244, 0.5); // 选中时的阴影效果更明显
  transform: scale(0.9); // 当选中时缩小复选框
}

.wx-radio-input.wx-radio-input-checked {
  // border: none !important;
}

/* #endif */

.container {
  height: 100%;

  .contentNoBg {
    margin-top: 110px;
  }

  .content {
    padding-top: 240px;
  }
}

.flex_row_start_center {
  display: flex;
  justify-content: flex-start;
  align-items: center;
  flex-direction: row;
}

.flex_row_start_top {
  display: flex;
  justify-content: flex-start;
  align-items: flex-start;
  flex-direction: row;
}

.flex_row_btw_center {
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-direction: row;
}

.flex_row_btw_top {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  flex-direction: row;
}

.flex_row_btw_end {
  display: flex;
  justify-content: space-between;
  align-items: flex-end;
  flex-direction: row;
}

.flex-column-between-between {
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-direction: column;
}

.flex-row-center-center {
  display: flex;
  justify-content: center;
  align-items: center;
  flex-direction: row;
}

.flex_row_btw_start {
  display: flex;
  justify-content: flex-start;
  align-items: center;
  flex-direction: row;
}

.flex_row_btw_start_no_align {
  display: flex;
  justify-content: flex-start;
  flex-direction: row;
}

.flex-column-between-end {
  display: flex;
  justify-content: flex-start;
  align-items: flex-end;
  flex-direction: column;
}

.flex-column-center-center {
  display: flex;
  justify-content: center;
  align-items: center;
  flex-direction: column;
}

.flex-column-between-start {
  display: flex;
  justify-content: flex-start;
  align-items: flex-start;
  flex-direction: column;
}

page {
  background-color: #f2f2f2;
}

// /* 调整遮罩层的样式 */
// :deep(.u-dropdown__content__mask) {
//   z-index: 1 !important; /* 遮罩层在浮动层下方 */
//   display: none !important;
// }
// :deep(.u_dropdown__content){
//   z-index: 1 !important; /* 遮罩层在浮动层下方 */
//   display: none !important;
// }
.priceFlow {
  font-family: PingFang SC, PingFang SC;
  font-weight: 500;
  font-size: 34rpx;
  color: #333333;
  height: 42rpx;
}
.priceHou {
  font-family: PingFang SC, PingFang SC;
  font-weight: 500;
  font-size: 24rpx;
  color: #333333;
  height: 32.5rpx;
}
.priceFlow1 {
  font-family: PingFang SC, PingFang SC;
  font-weight: 500;
  font-size: 45rpx;
  color: #333333;
  height: 42rpx;
}
.priceHou1 {
  font-family: PingFang SC, PingFang SC;
  font-weight: 500;
  font-size: 30rpx;
  color: #333333;
  height: 34.5rpx;
}
</style>
